class MyHashMap {
    class Node{
        public int val;
        public int key;
        public Node next;
        public Node(int key,int val){
            this.val=val;
            this.key=key;
        }
    }
    Node[] map=new Node[9];
    public void put(int key, int value) {
        int index=getIndex(key);
        Node cur=map[index];
        Node prev=cur;
        while(cur!=null){
            if(cur.key==key){
                cur.val=value;
                return ;
            }
            cur=cur.next;
        }
        Node node=new Node(key,value);
        node.next=map[index];
        map[index]=node;
    }

    public int get(int key) {
        int index=getIndex(key);
        Node cur=map[index];
        while(cur!=null){
            if(cur.key==key){
                return cur.val;
            }
            cur=cur.next;
        }
        return -1;
    }

    public void remove(int key) {
        int index=getIndex(key);
        Node cur=map[index];
        Node prev=null;
        while(cur!=null){
            if(cur.key==key){
                if(prev==null){
                    map[index]=cur.next;
                }else{
                    prev.next=cur.next;
                }
                return;
            }
            prev=cur;
            cur=cur.next;
        }
    }

    public int getIndex(int key){
        int hash=Integer.hashCode(key);
        hash^=(hash>>>16);
        return hash%map.length;
    }
}